import { createStore } from 'redux'

const initState = {
	supTian: 0,
	oppTian: 0,
	supTianPercent: '0'
}

const reducer = (state = initState, action) => {
	state = { ...state }
	switch (action.type) {
		case 'SUP_TIAN':
			state.supTian++
			break
		case 'OPP_TIAN':
			state.oppTian++
			break
	}
	state.supTianPercent = ((state.supTian / (state.supTian + state.oppTian)) * 100).toFixed(2)
	return state
}

const store = createStore(reducer)
export default store